package com.isczy.oss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/********************************************
 * @Brief: 读取Yaml常量类
 * @Version: 1.0
 * @Date: 2020年12月30日 10:04:04
 * @Author: ChangZiYang
 * ******************************************
 */
@Component
public class YamlConstant implements InitializingBean {

    @Value("${aliyun.oss.endpoint}")
    private String endpoint;

    @Value("${aliyun.oss.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.oss.accessKeySecret}")
    private String accessKeySecret;

    @Value("${aliyun.oss.bucketName}")
    private String bucketName;

    private YamlConstant(){}

    public static String ENDPOINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        YamlConstant.ENDPOINT = this.endpoint;
        YamlConstant.ACCESS_KEY_ID = this.accessKeyId;
        YamlConstant.ACCESS_KEY_SECRET = this.accessKeySecret;
        YamlConstant.BUCKET_NAME = this.bucketName;
    }
}
